package com.infolab.aims.domain.asset;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

@Embeddable
public class AssetTransactionItemPK implements Serializable {
	
	@ManyToOne
	@JoinColumn(name="assetTransactionId")
	private AssetTransaction assetTransaction;
	
	private Integer itemNo;

	public AssetTransaction getAssetTransaction() {
		return assetTransaction;
	}

	public void setAssetTransaction(AssetTransaction assetTransaction) {
		this.assetTransaction = assetTransaction;
	}

	public Integer getItemNo() {
		return itemNo;
	}

	public void setItemNo(Integer itemNo) {
		this.itemNo = itemNo;
	}
	
	@Override
	public boolean equals(Object obj) {
	
		return EqualsBuilder.reflectionEquals(this, obj);
	}
	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	@Override
	public String toString() {
	
		if(assetTransaction==null) return "Item No "+itemNo;
		return "Asset Transaction ID : "+ assetTransaction.getAssetTransactionId()+", Item No : "+itemNo; 
	}
	
	
}
